Skip to content

resolves #283 align study create with API spec#284

Draft
SeanAlexanderHarris wants to merge 6 commits intomainfrom
#283/align-study-create-with-api-spec
Draft

resolves #283 align study create with API spec#284
SeanAlexanderHarris wants to merge 6 commits intomainfrom
#283/align-study-create-with-api-spec

Conversation

@SeanAlexanderHarris
Copy link
Contributor

@SeanAlexanderHarris SeanAlexanderHarris commented Jan 20, 2026

Summary

Updates the study create command to align with the latest Prolific API specification, adding support for new fields while maintaining backward compatibility with deprecated fields. Add support for new API fields including completion_codes array, access_details, filter sets, content warnings, and metadata while maintaining backward compatibility with deprecated fields.

Changes

New Features

  • Completion Codes Array: Replaced single completion_code with completion_codes array supporting multiple codes with types (COMPLETED, REJECTED) and actions
    (AUTOMATICALLY_APPROVE, AUTOMATICALLY_REJECT)
  • Access Details: Added access_details array for taskflow studies with multiple URLs and allocations
  • Filter Sets: Added filter_set_id and filter_set_version for predefined filter configurations
  • Content Warnings: Added content_warnings array and content_warning_details for study content flagging
  • Custom Metadata: Added flexible metadata field for custom key-value pairs
  • Security: Added is_external_study_url_secure flag for JWT-secured external URLs
  • Custom Screening: Added is_custom_screening boolean flag
  • Auto-rejection: Added auto_rejection_categories to submissions_config

Backward Compatibility

The following fields are now DEPRECATED but still supported:

  • completion_code and completion_option (use completion_codes instead)
  • access_details_collection_id (use access_details instead)
  • eligibility_requirements (use filters or filter_set_id instead)

Documentation Updates

  • Updated command help text with new completion_codes format examples
  • Updated standard-sample.yaml example with new fields
  • Added inline comments documenting all new optional fields

Testing

Added test coverage in model/study_test.go:

  • Unmarshaling tests for new structs (CompletionCode, AccessDetail)
  • Integration tests for CreateStudy with new fields
  • Backward compatibility tests for deprecated fields

Manually tested with the edited standard templates in json and yaml

Files Changed

  • model/study.go : Core data model updates
  • model/study_test.go : Comprehensive test coverage
  • cmd/study/create.go : Command documentation updates
  • docs/examples/standard-sample.yaml : Updated example
  • docs/examples/standard-sample.json : Updated example
  • cmd/study/create_test.go : Test fixture update

Note

Aligns study creation with the latest API by introducing new fields, types, and examples while retaining deprecated fields for backward compatibility.

  • Model updates: add CompletionCode, CompletionCodeAction, AccessDetail; extend CreateStudy with completion_codes, access_details, filter_set_id/version, is_custom_screening, content_warnings, metadata, is_external_study_url_secure; keep deprecated completion_code, completion_option, access_details_collection_id, and eligibility_requirements; add auto_rejection_categories to submissions_config.
  • CLI/docs: refresh study create help and standard sample JSON/YAML to use completion_codes; adjust example maximum_allowed_time to 100.
  • Tests: add unmarshalling and integration tests for new fields and ensure backward compatibility; update command tests/fixtures accordingly.

Written by Cursor Bugbot for commit 0e94e5e. This will update automatically on new commits. Configure here.

Add support for new API fields including completion_codes array, access_details, filter sets, content warnings, and metadata while maintaining backward compatibility with deprecated fields.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@prolific-snyk
Copy link

prolific-snyk commented Jan 20, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@SeanAlexanderHarris SeanAlexanderHarris changed the title feat: align study create with API spec #283 feat: align study create with API spec Jan 20, 2026
@SeanAlexanderHarris SeanAlexanderHarris changed the title #283 feat: align study create with API spec resolves #283 align study create with API spec Jan 20, 2026
@SeanAlexanderHarris SeanAlexanderHarris self-assigned this Jan 20, 2026
@SeanAlexanderHarris
Copy link
Contributor Author

Claude drafted. Reviewing and testing.

@SeanAlexanderHarris SeanAlexanderHarris marked this pull request as ready for review January 22, 2026 23:56
@SeanAlexanderHarris SeanAlexanderHarris requested a review from a team as a code owner January 22, 2026 23:56
Copilot AI review requested due to automatic review settings January 22, 2026 23:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Aligns study create with the updated Prolific API create-study schema by extending the Go model, updating examples/help text, and adding tests to cover the new payload shapes and backward-compatible deprecated fields.

Changes:

  • Added new study-create model fields/structs (completion codes array, access details, filter set config, content warnings, metadata, security/custom-screening flags, auto-rejection categories).
  • Expanded model/study_test.go with JSON unmarshal tests for new and deprecated fields.
  • Updated CLI help text and example fixtures/docs to reflect the new format (partially).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
model/study.go Adds new request/response model fields and supporting structs for API-aligned study creation.
model/study_test.go Adds tests covering unmarshalling new structs and backward-compatible deprecated fields.
cmd/study/create.go Updates command example/help text to show the new completion codes format.
cmd/study/create_test.go Updates test fixtures to match updated example payloads/struct fields.
docs/examples/standard-sample.yaml Updates YAML example to use completion_codes format.
docs/examples/standard-sample.json Updates JSON example timing value (but still uses deprecated completion_code format).

AccessDetailsCollectionID string `json:"access_details_collection_id,omitempty" mapstructure:"access_details_collection_id"`
// Data collection method: "AI_TASK_BUILDER", "DC_TOOL", or "HUMAN_SIGNAL"

// Data collection method: "AI_TASK_BUILDER"
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment says the only valid data_collection_method is "AI_TASK_BUILDER", but the repo already includes examples using other values (e.g. docs/examples/standard-sample-aitaskbuilder.json uses "DC_TOOL"). Please update the comment to reflect the supported enum values so it doesn't mislead users.

Suggested change
// Data collection method: "AI_TASK_BUILDER"
// Data collection method. Enum: "AI_TASK_BUILDER", "DC_TOOL"

Copilot uses AI. Check for mistakes.
Comment on lines +60 to +61
"code_type": "FAILED_ATTENTION_CHECK",
"actions": [{"action": "MANUALLY_REVIEW"}]
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command help example uses completion_codes with code_type "FAILED_ATTENTION_CHECK" and action "MANUALLY_REVIEW", but those values don't appear anywhere else in the repo’s documented examples. To avoid users copying an example that the API may reject, consider using code_type/action values already demonstrated in docs/examples (e.g. COMPLETED / FOLLOW_UP_STUDY with AUTOMATICALLY_APPROVE, or align with the new REJECTED/AUTOMATICALLY_REJECT usage in model/study_test.go).

Suggested change
"code_type": "FAILED_ATTENTION_CHECK",
"actions": [{"action": "MANUALLY_REVIEW"}]
"code_type": "REJECTED",
"actions": [{"action": "AUTOMATICALLY_REJECT"}]

Copilot uses AI. Check for mistakes.
t.Errorf("expected max_submissions_per_participant to be 5, got %d", study.SubmissionsConfig.MaxSubmissionsPerParticipant)
}
if len(study.SubmissionsConfig.AutoRejectionCategories) != 1 {
t.Fatalf("expected 2 auto_rejection_categories, got %d", len(study.SubmissionsConfig.AutoRejectionCategories))
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The assertion expects len(AutoRejectionCategories) == 1, but the failure message says "expected 2 auto_rejection_categories". Update the message to match the expected length so failures are actionable.

Suggested change
t.Fatalf("expected 2 auto_rejection_categories, got %d", len(study.SubmissionsConfig.AutoRejectionCategories))
t.Fatalf("expected 1 auto_rejection_categories, got %d", len(study.SubmissionsConfig.AutoRejectionCategories))

Copilot uses AI. Check for mistakes.
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

This PR is being reviewed by Cursor Bugbot

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

t.Errorf("expected max_submissions_per_participant to be 5, got %d", study.SubmissionsConfig.MaxSubmissionsPerParticipant)
}
if len(study.SubmissionsConfig.AutoRejectionCategories) != 1 {
t.Fatalf("expected 2 auto_rejection_categories, got %d", len(study.SubmissionsConfig.AutoRejectionCategories))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test error message expects wrong count

Low Severity

The test error message states "expected 2 auto_rejection_categories" but the test condition checks for exactly 1 category (!= 1), and the test data contains only 1 category. The error message incorrectly claims 2 categories are expected when only 1 is expected.

Fix in Cursor Fix in Web

Matt2298
Matt2298 previously approved these changes Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants